home *** CD-ROM | disk | FTP | other *** search
/ Resource Library: Multimedia / Resource Library: Multimedia.iso / maestro / source / cdedit / connect.c < prev    next >
Encoding:
C/C++ Source or Header  |  1993-06-15  |  4.9 KB  |  142 lines

  1. /*
  2.  * Copyright (c) 1990, 1991 Stanford University
  3.  *
  4.  * Permission to use, copy, modify, and distribute this software and 
  5.  * its documentation for any purpose is hereby granted without fee, provided
  6.  * that (i) the above copyright notices and this permission notice appear in
  7.  * all copies of the software and related documentation, and (ii) the name
  8.  * Stanford may not be used in any advertising or publicity relating to
  9.  * the software without the specific, prior written permission of
  10.  * Stanford.
  11.  * 
  12.  * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, 
  13.  * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY 
  14.  * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.  
  15.  *
  16.  * IN NO EVENT SHALL STANFORD BE LIABLE FOR ANY SPECIAL, INCIDENTAL,
  17.  * INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, OR ANY DAMAGES
  18.  * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER OR NOT
  19.  * ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF LIABILITY,
  20.  * ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
  21.  * SOFTWARE.
  22.  */
  23.  
  24. /* $Header: /Source/Media/collab/cdEdit/RCS/connect.c,v 2.0 91/10/06 21:01:15 chua Exp $ */
  25. /* $Log:    connect.c,v $
  26.  * Revision 2.0  91/10/06  21:01:15  chua
  27.  * Update to version 2.0
  28.  * 
  29.  * Revision 1.11  91/09/04  11:35:08  chua
  30.  * Delete the temphostName variable in ConnectPortManager. (not used)
  31.  * 
  32.  * Revision 1.10  91/09/03  15:34:27  chua
  33.  * Rename the version number to 1.10 from 0.99
  34.  * 
  35.  * Revision 0.99  91/09/03  14:44:08  chua
  36.  * This file contains the functions that deal with the PortManager popup window and the
  37.  * connecting and disconnecting to port managers.
  38.  * 
  39.  * The functions are:
  40.  * 
  41.  * NewPortManager: text notify function for the new port manager field in the PortManager
  42.  *            popup window.  This will call the ConnectPortManager function.
  43.  * 
  44.  * ConnectPortManager: Tries to create a connection with the port manager specified in
  45.  *                 the new port manager textfield. If successful, disconnect from the
  46.  *                previous port manager.
  47.  * 
  48.  * ClosePortManagerPopup: Closes the PortManager popup window.
  49.  * 
  50.  * ConnectPortManagerHandler: Opens the PortManager popup window.
  51.  *  */
  52.  
  53. static char connectrcsid[] = "$Header: /Source/Media/collab/cdEdit/RCS/connect.c,v 2.0 91/10/06 21:01:15 chua Exp $";
  54.  
  55. #include "main.h"
  56.  
  57. Sender *tempSender;
  58.  
  59. /*
  60.  * Notify callback function for `NewPortManagerText'.
  61.  * Calls the notify function for the ConnectPortManagerButton when a return is pressed.
  62.  */
  63. Panel_setting NewPortManager(item, event)
  64.      Panel_item    item;
  65.      Event        *event;
  66. {
  67.   ConnectPortManager(item, NULL);
  68.   return panel_text_notify(item, event);
  69. }
  70.  
  71. /*
  72.  * Notify callback function for `ConnectPortManagerButton'.
  73.  * This function will take the name specifed on the NewPortManagerText textfield and attempt to make a connection 
  74.  * with the port manager on this host.  If it succeeds, it will disconnect from the previous port manager it was connected to (if any).
  75.  */
  76. void ConnectPortManager(item, event)
  77.      Panel_item    item;
  78.      Event        *event;
  79. {
  80.   char buf[100];
  81.   ConnectPortManager_PortManagerPopup_objects    *ip = (ConnectPortManager_PortManagerPopup_objects *) xv_get(item, XV_KEY_DATA, INSTANCE);
  82.  
  83.   if (strcmp(senderPort.hostName, (char *) xv_get(ip->NewPortManagerText, PANEL_VALUE)) == 0) /* Do not reconnect if it is the same host */
  84.   {
  85.     return;
  86.   }
  87.   strcpy(senderPort.hostName, (char *) xv_get(ip->NewPortManagerText, PANEL_VALUE));
  88.   tempSender = NewSender(&senderPort);
  89.   if (tempSender)
  90.   {
  91.     if (sender && receiver)                        /* Disconnect from previous Port Manager (if any) */
  92.     {
  93.       DestroyReceiver(sender, receiver);
  94.     }
  95.     sender = tempSender;
  96.     receiver = NewReceiver(sender, "cdEdit", ReceiverPortNumber);
  97.     sprintf(buf, "Current Port Manager : %s\n", senderPort.hostName);
  98.     xv_set(ip->CurrentPortManagerMsg, PANEL_LABEL_STRING, buf, NULL);
  99.   }
  100.   else 
  101.   {
  102.     AlertMessage("Failed to connect with the PortManager.",
  103.          "Check that the hostname is valid, and that the PortManager is running on it.");
  104.   }
  105. }
  106.  
  107. /*
  108.  * Notify callback function for `ClosePortManagerPopupButton'.
  109.  * Close the Connect Port Manager popup window
  110.  */
  111. void ClosePortManagerPopup(item, event)
  112.      Panel_item    item;
  113.      Event        *event;
  114. {
  115.   xv_set(cdEdit_PortManagerPopup->PortManagerPopup, FRAME_CMD_PUSHPIN_IN, FALSE, NULL);
  116.   xv_set(cdEdit_PortManagerPopup->PortManagerPopup, XV_SHOW, FALSE, NULL);
  117. }
  118.  
  119. /*
  120.  * Menu handler for `OptionsMenu (Connect with new Port Manager ...)'.
  121.  * Open the popup window to choose a new port manager to connect to.
  122.  */
  123. Menu_item ConnectPortManagerHandler(item, op)
  124.      Menu_item    item;
  125.      Menu_generate    op;
  126. {
  127.   switch (op) 
  128.   {
  129.    case MENU_DISPLAY:
  130.     break;
  131.    case MENU_DISPLAY_DONE:
  132.     break;
  133.    case MENU_NOTIFY:
  134.     xv_set(cdEdit_PortManagerPopup->PortManagerPopup, FRAME_CMD_PUSHPIN_IN, TRUE, NULL);
  135.     xv_set(cdEdit_PortManagerPopup->PortManagerPopup, XV_SHOW, TRUE, NULL);
  136.     break;
  137.    case MENU_NOTIFY_DONE:
  138.     break;
  139.   }
  140.   return item;
  141. }
  142.